<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Websocket handler for onOpen and onClose callback
    | Replace this handler if you want to customize your websocket handler
    |--------------------------------------------------------------------------
     */
    'handler' => SwooleTW\Http\Websocket\SocketIO\WebsocketHandler::class,

    /*
    |--------------------------------------------------------------------------
    | Default frame parser
    | Replace it if you want to customize your websocket payload
    |--------------------------------------------------------------------------
     */
    'parser' => SwooleTW\Http\Websocket\SocketIO\SocketIOParser::class,

    /*
    |--------------------------------------------------------------------------
    | Websocket route file path
    |--------------------------------------------------------------------------
     */
    'route_file' => base_path('routes/websocket.php'),

    /*
    |--------------------------------------------------------------------------
    | Default middleware for on connect request
    |--------------------------------------------------------------------------
     */
    'middleware' => [
        // SwooleTW\Http\Websocket\Middleware\DecryptCookies::class,
        // SwooleTW\Http\Websocket\Middleware\StartSession::class,
        // SwooleTW\Http\Websocket\Middleware\Authenticate::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Default websocket driver
    |--------------------------------------------------------------------------
     */
    'default' => 'table',

    /*
    |--------------------------------------------------------------------------
    | Websocket client's heartbeat interval (ms)
    |--------------------------------------------------------------------------
     */
    'ping_interval' => 25000,

    /*
    |--------------------------------------------------------------------------
    | Websocket client's heartbeat interval timeout (ms)
    |--------------------------------------------------------------------------
     */
    'ping_timeout' => 60000,

    /*
    |--------------------------------------------------------------------------
    | Room drivers mapping
    |--------------------------------------------------------------------------
     */
    'drivers' => [
        'table' => SwooleTW\Http\Websocket\Rooms\TableRoom::class,
        'redis' => SwooleTW\Http\Websocket\Rooms\RedisRoom::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Room drivers settings
    |--------------------------------------------------------------------------
     */
    'settings' => [

        'table' => [
            'room_rows' => 4096,
            'room_size' => 2048,
            'client_rows' => 8192,
            'client_size' => 2048,
        ],

        'redis' => [
            'server' => [
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', 111111),
                'port' => env('REDIS_PORT', 6379),
                'database' => 0,
                'persistent' => true,
            ],
            'options' => [
                //
            ],
            'prefix' => 'swoole:',
        ],

        'swoole' => [
            'swoole9503' => [
                'server' => [
                    'host' => env('SWOOLE_WEBSOCKET_HOST', '0.0.0.0'),
                    'port' => env('SWOOLE_WEBSOCKET_PORT', 9503),
                ],
                'options' => [
                    'worker_num' => swoole_cpu_num(), //进程数
                    'reactor_num' => swoole_cpu_num(),
                    'task_worker_num' => swoole_cpu_num(),
                    'daemonize' => 1, //守护进程化
                    'log_file' => env('SWOOLE_WEBSOCKET_LOG_FILE', base_path('storage/logs/swoole_websocket9503.log')),
                    'pid_file' => env('SWOOLE_WEBSOCKET_PID_FILE', base_path('storage/logs/swoole_websocket9503.pid')),
                    'max_request' => 100, //进程的最大任务数
                    'dispatch_mode' => 2, //固定模式
                    'debug_mode' => 1,
                    'heartbeat_check_interval' => 60,//心跳检测60秒
                    'heartbeat_idle_time' => 120,//心跳超时断开时间
                ],
                'tables' => [
                    'barrage' => [
                        'size' => 1024,
                        'columns' => [
//                        ['name' => 'fd','type'=> \BulletSwoole\Table::TYPE_INT,'size'=>4],
//                        ['name' => 'msg','type'=> \BulletSwoole\Table::TYPE_STRING,'size'=>255],
//                        ['name' => 'time','type'=> \BulletSwoole\Table::TYPE_INT,'size'=>8],
                        ]
                    ]
                ]
            ],
            'swoole9504' => [
                'server' => [
                    'host' => env('SWOOLE_WEBSOCKET_HOST', '0.0.0.0'),
                    'port' => env('SWOOLE_WEBSOCKET_PORT', 9504),
                ],
                'options' => [
                    'worker_num' => swoole_cpu_num(), //进程数
                    'reactor_num' => swoole_cpu_num(),
                    'task_worker_num' => swoole_cpu_num(),
                    'daemonize' => 1, //守护进程化
                    'log_file' => env('SWOOLE_WEBSOCKET_LOG_FILE', base_path('storage/logs/swoole_websocket9504.log')),
                    'pid_file' => env('SWOOLE_WEBSOCKET_PID_FILE', base_path('storage/logs/swoole_websocket9504.pid')),
                    'max_request' => 100, //进程的最大任务数
                    'dispatch_mode' => 5, //UID 分配
                    'debug_mode' => 1,
                    'heartbeat_check_interval' => 60,//心跳检测60秒
                    'heartbeat_idle_time' => 600,//心跳超时断开时间
                ],
                'tables' => [
                    'barrage' => [
                        'size' => 1024,
                        'columns' => [
//                        ['name' => 'fd','type'=> \BulletSwoole\Table::TYPE_INT,'size'=>4],
//                        ['name' => 'msg','type'=> \BulletSwoole\Table::TYPE_STRING,'size'=>255],
//                        ['name' => 'time','type'=> \BulletSwoole\Table::TYPE_INT,'size'=>8],
                        ]
                    ]
                ]
            ]
        ],
    ],
];
